#ifndef NANE_LOGMANAGER_H
#    define NANE_LOGMANAGER_H

#   include "nane/core/ILogSystem.h"
#   include "nane/core/Holder.h"
#   include "nane/core/crt/Context.h"

namespace nane
{
    template<class S>
    class LogSystemHolder
        : public Holder<S>
    {
    };
    
    template<>
    class LogSystemHolder<ILogSystem>
        : public Holder<ILogSystem>
    {
    public:
        static ILogSystem* Instance()
        {
            if( s_instance == NULL )
            {
                s_instance = nane::m_context->logSystem;
            }
            return s_instance;            
        }
    };
    
    class LogManager
    {
    public:
        static bool Initialize( bool _enableStdLogger = true );
        static void Shutdown();
        
        static void RegisterLogger( ILogger* _logger )
        {
            LogSystemHolder<ILogSystem>::Instance()->RegisterLogger(_logger);
        }
        
        static void UnregisterLogger( ILogger* _logger )
        {
            LogSystemHolder<ILogSystem>::Instance()->UnregisterLogger(_logger);
        }
        
        static void Log( const char* _message, const char* _file, const char* _line, const char* _function, ELogMessageLevel _messageLevel )
        {
            LogSystemHolder<ILogSystem>::Instance()->Log(_message, _file, _line, _function, _messageLevel.raw_value());
        }
        
        static void SetMessagesLevel( ELogMessageLevel _messagesLevel )
        {
            LogSystemHolder<ILogSystem>::Instance()->SetMessagesLevel(_messagesLevel.raw_value());
        }

    private:
        class Implementation;
    };

} // namespace nane

#endif // NANE_LOGMANAGER_H
